package base.rand;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.junit.Test;

public class RandCode {

	@Test
	public void randCOde() {
		Random random = new Random();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		int t;
		int column = 600;
		int row = 200;
		Integer c;
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < column; j++) {
				t = random.nextInt(10);
				c = map.get(t);
				if (c == null) {
					c = 0;
				}
				c++;
				map.put(t, c);

				// System.out.print(t + " ");
			}
			System.out.println();
		}
		System.out.println("========================================");
		for (int i = 0; i < 10; i++) {
			System.out.println(i + "的概率是：" + map.get(i) + "/" + column * row);
		}

	}
}
